package com.zhoutao.blog.seven.model.converter;

import com.zhoutao.blog.seven.dao.model.BookDao;
import com.zhoutao.blog.seven.model.response.Book;
import com.zhoutao.blog.seven.utils.TimeUtils;
import org.springframework.stereotype.Component;

@Component
public class BookConverter extends AbstractConverter<BookDao, Book> {

    @Override
    public Book converterFrom(BookDao bookDao) {
        return new Book()
                .setId(bookDao.getId())
                .setBookName(bookDao.getBookName())
                .setBookKey(bookDao.getBookKey())
                .setReadCount(bookDao.getReadCount())
                .setCoverUrl(bookDao.getCoverUrl())
                .setLink("/" + bookDao.getBookKey())
                .setRemark(bookDao.getRemark())
                .setOrdinal(bookDao.getOrdinal())
                .setCreatedAt(TimeUtils.format(bookDao.getCreatedAt()));

    }

    @Override
    public BookDao converterTO(Book book) {
        return null;
    }
}
